package com.ash.socketa.simple;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class ServerSimpleDemo {


    public static void main(String[] args) throws IOException {


        try (ServerSocket serverSocket = new ServerSocket(8082);
             Socket accept = serverSocket.accept();
             InputStream inputStream = accept.getInputStream();) {
            byte[] bytes = new byte[1024];
            int len;
            StringBuilder sb = new StringBuilder();
            while ((len = inputStream.read(bytes)) != -1) {
                sb.append(new String(bytes, 0, len, StandardCharsets.UTF_8));
            }

            System.out.println(sb);
        }


    }
}
